<template>
  <div>
    <h1>Home</h1>
    <ul>
      <li v-for="item in posts" :key="item.id">
        {{ item.title }}
      </li>
    </ul>
  </div>
</template>

<script>
import { mapState, mapActions } from 'vuex';
export default {
  name: 'Home',
  metaInfo: {
    title: '首页',
  },
  computed: {
    ...mapState(['posts']),
  },
  serverPrefetch() {
    return this.getPosts();
  },
  methods: {
    ...mapActions(['getPosts']),
  },
};
</script>
